        .xlist
; Include file - OSSIBO.INC
; Epoc/Os Sibo include file.
; Copyright (c) Psion PLC 1989-90.
;
;  VER    DATE    BY  DESCRIPTION
; ----- -------- ---- -----------
; 2.00F 30/09/90 NSM  Final release
;
NoNullFrames		equ	1
;
if	Asic1
A1Ent	struc
A1Dummy			dw	?
A1Control		dw	?
A1LcdSize		dw	?
A1LcdControl		dw	?
A1InterruptMask		dw	?
A1NonSpecificEoi	dw	?
A1TimerEoi		dw	?
A1FrcEoi		dw	?
A1ResetWatchDog		dw	?
A1FrcControl		dw	?
A1ProtectionOn		dw	?
A1ProtectionUpper	dw	?
A1ProtectionLower	dw	?
A1SoundLsw		dw	?
A1SoundMsw		dw	?
A1SoundControl		dw	?
A1Ent ends
;
A1Status		equ	A1Control
A1ProtectionOff		equ	A1ProtectionOn
A1InterruptStatus	equ	A1LcdControl
;
A1StatusR record LcdData:2,Rtc4Hz:1,SldMsw:1,ComboBusy:1,Rtc32Hz:1,ExternalNmi:1,WatchDogNmi:1,SldTx:1,A1SldEnable:1,LcdEnable:1,Ram512:1,Ram128:1,FrcSource:1,TickRate:1,FrcMode:1
A1LcdSizeR record LcdMLineEnable:1,LcdNumberOfPixels:5,LcdEndOfFrame:10
A1LcdControlR record LcdMode:2,LcdMLineRate:5,LcdRate:5
A1InterruptMaskR record SldTransmit:1,SldReceive:1,FrcExpired:1,Asic2Int:1,ExpIntLeftA:1,ExpIntRightB:1,Mains:1,Timer:1
ExpAddressLeftA		equ	0200h
ExpAddressRightB	equ	0100h
ExpChannelLeftA		equ	SelectChannel6
ExpChannelRightB	equ	SelectChannel5
;
; Asic1 dependent constants
;
ResetWatchDog		equ	A1ResetWatchDog
;
A2Ent struc
A2Dummy			db	080h dup(?)
A2Index			dw	?
A2Control		dw	?
A2Control1		dw	?
A2Control2		dw	?
A2Control3		dw	?
A2SerialData		dw	?
A2SerialControl		dw	?
A2ChannelControl	dw	?
A2Ent ends
;
A2External		equ	A2Control1
A2InterruptStatus	equ	A2Control2
A2Status		equ	A2Control3
A2KeyData		equ	A2SerialControl
A2SlaveData		equ	A2ChannelControl
A2IControl0		equ	0
A2IControl1		equ	1
A2IWrite		equ	2
A2IDDR			equ	3
;
A2InterruptStatusR record SlaveDataOverrun:1,SlaveDataControl:1,SlaveDataValid:1,ExpansionInterrupt:1,DoorInterrupt:1
A2StatusR record A2RevId:1,A2XExt:1,A2Sdis:1,SerialBusy:1,SerialClockState:1,A1ResetFlag:1,WakeUp:1,A1OnKey:1
A2Control1R record SerialClockRate:2,KeyScan:4
A2Control2R record ClockEnable7:1,ClockEnable6:1,ClockEnable5:1,BuzzerMode:1,BuzzerVolume:1,BuzzerToggle:1,XySwitch:1,DigitizerEnable:1
A2Control3R record ElEnable:1,VhControl:1,ExpansionEnable:1,DoorEnable:1,SerialEnable:1,A2SldEnable:1,Ps34Acknowledge:1,SerialNull:1
A2ChannelControlR record MultiplexEnable:1,ChannelSelect:3,Pack4Enable:1,Pack3Enable:1,Pack2Enable:1,Pack1Enable:1
;
ClockRateSlow		equ	2
ClockRateMedium		equ	0
ClockRateFast		equ	3
SelectChannel0		equ	(4 shl ChannelSelect)
SelectChannel1		equ	(mask Pack1Enable)
SelectChannel2		equ	(mask Pack2Enable)
SelectChannel3		equ	(mask Pack3Enable)
SelectChannel4		equ	(mask Pack4Enable)
SelectChannel5		equ	(5 shl ChannelSelect)
SelectChannel6		equ	(6 shl ChannelSelect)
SelectChannel7		equ	(7 shl ChannelSelect)
;
SCONTOUT macro
	out	A2SerialControl, al
	endm
;
SDATAOUT macro
	out	A2SerialData, al
	endm
;
SDATAIN macro
	in	al, A2SerialData
	endm
;
SBUSY	macro
        wait
	endm
;
SREAD	macro _REG
	mov	al, SerialReadSingle or _REG
	out	A2SerialControl, al
	nop
	SBUSY
	in	al, A2SerialData
	endm
;
SREADM	macro _REG
	mov	al, SerialReadMulti or _REG
	out	A2SerialControl, al
	nop
	SBUSY
	in	al, A2SerialData
	endm
;
SWRITE	macro _REG,_VAL
	mov	al, SerialWriteSingle or _REG
	out	A2SerialControl, al
	SBUSY
	mov	al, _VAL
	out	A2SerialData, al
	endm
;
SWRITEM macro _REG,_VAL
	mov	al, SerialWriteMulti or _REG
	out	A2SerialControl, al
	SBUSY
	mov	al, _VAL
	out	A2SerialData, al
	endm
;
SETSPEED macro _SPEED
	pushf
	cli
	mov	al, OsA2Control1
	and	al, not mask SerialClockRate
  ifidni <_SPEED>,<FAST>
	or	al, ClockRateFast shl SerialClockRate
  endif
  ifidni <_SPEED>,<NORMAL>
	or	al, ClockRateMedium shl SerialClockRate
  endif
  ifidni <_SPEED>,<SLOW>
	or	al, ClockRateSlow shl SerialClockRate
  endif
	mov	OsA2Control1, al
	out	A2Control1, al
	popf
	endm
;
  if	LapTop
XPUSHFCLI macro
	pushf
	cli
	endm
XPOPF	macro
	popf
	endm
  else
XPUSHFCLI macro
	endm
XPOPF	macro
	endm
  endif
;
XNOP	macro
	endm
;
@HwNullFrame macro
	call	OsHwNullFrame
        endm
;
A3Ent struc
A3Adc			db	?
A3Control1		db	?
A3Setup			db	?
A3Control2		db	?
A3Dummy1		db	3 dup (?)
A3Control3		db	?
A3Dummy2		db	5 dup (?)
A3Status		db	?
A3Dummy3		db	?
A3Ent ends
;
A3AdcLsbR record InvertedBit:1,OtherBits:7
A3AdcMsbR record Polarity:1,Overrange:1,AdcBits:4
A3Control1R record Vcc5Enable:1,Vcc4Enable:1,Vcc3Enable:1,DtoaBits:5
A3Control2R record AnalogueMultiplex:2,VhSoftStart:1,Vee2SoftStart:1,Vee1SoftStart:1,VhEnable:1,Vee2Enable:1,Vee1Enable:1
A3Control3R record AdcReadHighEnable:1,OffEnable:1,xDummy1:1
Ps34ControlR record Ps34Vcc3:1,xDummy2:1,Ps34Vcc4:1,xDummy3:1,Ps34Vcc5:1,xDummy4:3
;
AdcDigitizer		equ	0
AdcVh			equ	1
AdcMainBattery		equ	2
AdcLithiumBattery	equ	3
A3SetupValue		equ	2
A3SelectId		equ	(SerialSelect or Asic5NormalId)
A3InfoByte		equ	080h
;
Vee1SoftStartDelay	equ	(30*128)
Vee2SoftStartDelay	equ	(30*128)
VhSoftStartDelay	equ	(100*128)
Vee1OffDelay		equ	(100*128)
Vee2OffDelay		equ	(100*128)
VhOffDelay		equ	(100*128)
Vcc3Delay		equ	(25*128)
Vcc4Delay		equ	(25*128)
Vcc5Delay		equ	(25*128)
Vcc4OffFrames		equ	(25)
Vcc1_4To5Delay		equ	(3)  ; Pan only in ms.
Vcc1_4to5OffFrames	equ	(20) ; Gives 392 frames = 6.0 ms
Vcc1_4to5OnTime		equ	4    ; Gives 4 ms
;
PS34R_ADC	equ	0
PS34R_STATUS	equ	1
PS34W_CONTROL	equ	0
PS34W_DTOA	equ	1
PS34W_OFF	equ	0eh
;
PS34STATR record pPowerFail:1,pColdStart:1,pVhready:1,pPenup:1,pNc:1,pAdmsb:3
PS34CONTR record pVcc3:1,pVee1:1,pVcc4:1,pVee2:1,pVcc5:1,pVh:1,pVhpower:2
PS34DTOAR record pNcc:1,pAdcsel:2,pDac:5
;
ADCSEL_ADCIN	equ	0
ADCSEL_VIN	equ	1
ADCSEL_VH	equ	2
ADCSEL_VBATT	equ	3
;
VHP1TO8		equ	0
VHP1TO4		equ	1
VHP1TO2		equ	2
VHP1TO1		equ	3
;
PPowerControl	equ	0100h
PPowerControlR	record	PVcc5Enable:1,PSoundEnable:1,PVee1Enable:1,PDropVoltage:1,PDac:4
PPia		record	PSoundVol:2,PClearCold:1,PDcPresent:1,PColdFlag:1,PLithiumWarn:1,PVinWarn:1
PSoundControl	equ	0200h
endif
;
A3StatusR record PowerFail:1,ColdStart:1
AIntfR    record ResetFlag:1,DummyWakeUp:1,OnKey:1
if	Asic1
  if	((mask ResetFlag) ne (mask A1ResetFlag)) or \
	((mask OnKey) ne (mask A1OnKey))
	.err	Reset or OnKey flags are not equal
  endif
endif
;
SerialWriteSingle	equ	10000000b
SerialWriteMulti	equ	10010000b
SerialReadSingle	equ	11000000b
SerialReadMulti		equ	11010000b
SerialReset		equ	00000000b
SerialSelect		equ	01000000b
;
Asic4Id			equ	006h
Asic5PackId		equ	002h
Asic5NormalId		equ	003h
Asic6Id			equ	004h
Asic8Id			equ	005h
Asic2SlaveId		equ	01fh
;
; Asic5 info byte structure
;
A5InfoByteR record A5TTL:1,A5Modem:1,A5MultiDrop:1,A5Barcode:1,A5Other:2,A5Parallel:1,A5Rs232:1
A5OtherRom	equ	(1 shl A5Other)
A5OtherMCRTTL	equ	(3 shl A5Other)
A5MCR		equ	(2 shl A5Other)
;
if	Consumer
  if	S3b
DefaultLcdContrast	equ	9
  else
DefaultLcdContrast	equ	7
  endif
else
if	S3c
DefaultLcdContrast	equ	9
else
DefaultLcdContrast	equ	15
endif
endif
;
InterruptBase		equ	078h
;
if	Asic9
KeyPollColumns        	equ	8
else
KeyPollColumns        	equ	10
endif
KeyInitialDelay		equ	24
if	Consumer or S3c
KeyRepeatDelay		equ	2
else
KeyRepeatDelay		equ	4
endif
PenUpDelay		equ	16
MouseDownDelay		equ	8
KeySettleDelay		equ	24
KeyCntrlMask		equ	00000001b
KeyLeftShiftMask	equ	00000010b
KeyPsionMask		equ	00000100b
KeyCapsMask		equ	00001000b
KeyRightShiftMask	equ	00010000b
DigitizerRowMask	equ	00010000b
PsionScanCode		equ 	6
CapsScanCode		equ	5
PsionUpScanCode		equ	65
;
PostRomTest		equ	010h
PostSystemRamTest	equ	020h
PostVideoRamTest	equ	030h
PostComplete		equ	0f0h
if	Consumer or S3c
PostPort		equ	0h
else
PostPort		equ	01ffh
endif
;
if	HandHeld
	VideoRamSegment		equ	00040h
	VideoRamBase		equ	00000h
  if	Corporate
	VideoRamWords		equ	00320h
  else
    if	S3b
	VideoRamWords		equ	02580h
    else
      if S3c
	VideoRamWords		equ	00C80h
      else
	VideoRamWords		equ	00500h
      endif
    endif
  endif
else
	VideoRamSegment		equ	0b800h
	VideoRamBase		equ	00000h
	VideoRamWords		equ	04000h
endif
;
CalSeg		equ	0fffeh
CalEnt	struc
CalVsupCLsw	dw	?
CalVsupCMsw	dw	?
CalVsupM	dw	?
CalVlthCLsw	dw	?
CalVlthCMsw	dw	?
CalVlthM	dw	?
CalType		dw	?
CalEnt	ends
;
CHKeyDataR record CHInSled:1,CHMains:1,CHDummy:2
;
IntBXHw		equ	-2
;
if	Asic9
A9WControlRW		equ	0002h
  A9RControl record	A9MFrc2Is512KHzOr1KHz:1,A9MFrc2PreScale:1,\
    			A9MFrc1Is512KHzOr1Hz:1,A9MFrc1PreScale:1,\
    			A9MSoundEnable:1,A9MLcdEnable:1,\
    			A9MLowBatNMIEnable:1,A9MDoorNMIEnable:1,\
    			A9MZeroIsGrayMode:1,A9MArmStandBy:1,\
    			A9MDisableDMADivide:1,A9MRamDeviceSize:2,\
    			A9MDisableMemWait:1,A9MDisableIoWait:1,\
    			A9MDisableClockDivide:1
  A9VRam256KBits	equ	(0 shl A9MRamDeviceSize)
  A9VRam1MBits		equ	(1 shl A9MRamDeviceSize)
  A9VRam4MBits		equ	(2 shl A9MRamDeviceSize)
  A9VRam16MBits		equ	(3 shl A9MRamDeviceSize)
  A9XRamDeviceSizeMask	equ	(3 shl A9MRamDeviceSize)
A9WStatusR		equ	0004h
  A9RStatus record	A9MCold:1,A9MPowerFail:1,\
    			A9MReset:1,A9MNoBattery:1,\
    			A9MFifoFull:1,A9MSlaveOverrun:1,\
    			A9MSlaveControlFrame:1,A9MSlaveDataValid:1,\
    			A9MKeyboard:1,A9MSlaveClock:1,\
    			A9MMainsPresent:1,A9MDoorSwitch:1,\
    			A9MLowBatNMI:1,A9MDoorNMI:1,\
    			A9MProtectedModeNMI:1,A9MWatchDogNMI:1
  A9MLcdType		equ	8
  A9XLcdType		equ	0000111100000000b
A9WLcdSizeW		equ	0004h
  A9RLcdSize record	A9MLcdLineLength:5,A9MLcdNumberOfPixels:11
A9WLcdControlW		equ	0006h
  A9RLcdControl record	A9MLcdMode:2,A9MLcdACLineRate:5,A9MLcdPixelRate:5
  A9VSinglePage1	equ	(0 shl A9MLcdMode)
  A9VSinglePage2	equ	(1 shl A9MLcdMode)
  A9VSinglePage1And2	equ	(2 shl A9MLcdMode)
  A9VDualPage1And2	equ	(3 shl A9MLcdMode)
A9BInterruptStatusR	equ	0006h
A9BInterruptMaskRW	equ	0008h
  A9RInterrupts record	A9MFrc2:1,A9MFrc1:1,\
    			A9MExpIntB:1,A9MExpIntA:1,A9MExpIntC:1,\
    			A9MSlave:1,A9MTimer:1,A9MSound:1
A9BNmiClearW		equ	0009h
A9BNonSpecificEoiW	equ	000ah
A9BStartFlagClearW	equ	000bh
A9BTimerEoiW		equ	000ch
A9BSerialSlaveEoiW	equ	000dh
A9BFrc1EoiW		equ	000eh
A9BFrc2EoiW		equ	000fh
A9WResetWatchDogW	equ	0010h
A9WFrc1DataRW		equ	0012h
A9BProtectionOnW	equ	0014h
A9BProtectionOffR	equ	0014h
A9BProtectionOffW	equ	0015h
A9WProtectionUpperW	equ	0016h
A9WProtectionLowerW	equ	0018h
A9BSoundDataRW		equ	001ah
A9BSoundEoiW		equ	001ch
A9WFrc2DataRW		equ	001eh
A9WPortABDataRW		equ	0020h
if	S3b
  A9RPortABData record  A9MKeyId0:1,A9MSleepDoorNmiDisabled:1,\
    			A9MBatLevel2:1,A9MBatLevel1:1,A9MLiBatLevel:1,\
    			A9MKeyRow:11
endif
if	S3c
  A9RPortABData record  A9MKeyIdX2:1,A9MNiCdDetect:1,\
    			A9MBatLevel2:1,A9MBatLevel1:1,A9MLiBatLevel:1,\
    			A9MKeyIdX1:1,A9MKeyIdX0:0,A9MKeyRowX8:1,\
    			A9MCradle:1,A9MKeyRowX:7
endif
A9BPortADataRW		equ	0020h
A9BPortBDataRW		equ	0021h
A9WPortABDDRRW		equ	0022h
  A9VPortABDDR		equ	0000000000000000b
A9BPortADDRRW		equ	0022h
A9BPortBDDRRW		equ	0023h
A9WPortCDDataRW		equ	0024h
if	S3b
  A9RPortCDData record	A9MVccPacksEnable:1,A9MCodecEnable:1,\
    			A9MVccLcdEnable:1,A9MLcdPanelEnable:1,\
    			A9MLcdContrast:4,A9MVolume:2,\
    			A9MReproEnable:1,A9MAltDoorNMIEnable:1,\
    			A9MAmplifierEnable:1,A9MKeyIdEnable:1,\
    			A9MKeyId2:1,A9MKeyId1:1
  A9VVolumeLow		equ	(mask A9MVolume)
  A9VPortCDData		equ	0000111100000000b
  A9VPortCDDDR		equ	not (1111000011111100b)
endif
if	S3c
  A9RPortCDData record	A9MVccPacksEnable:1,A9MCodecEnable:1,\
    			A9MVccLcdEnable:1,A9MLcdPanelEnable:1,\
    			A9MLcdContrast:4,A9MVolume:2,\
    			A9MReproEnable:1,A9MAltDoorNMIEnable:1,\
    			A9MAmplifierEnable:1,A9MKeyIdEnable:1,\
    			A9MBuzVolX:1,A9MBacklightEnableX:1
  A9VVolumeLow		equ	(mask A9MVolume)
  A9VPortCDData		equ	0000111100000000b
  A9VPortCDDDR		equ	not (1111000011111111b)
endif
A9BPortCDataRW		equ	0024h
A9BPortDDataRW		equ	0025h
A9WPortCDDDRRW		equ	0026h
A9BPortCDDRRW		equ	0026h
A9BPortDDDRRW		equ	0027h
A9BPageSelect6000RW	equ	0028h
A9BPageSelect7000RW	equ	0029h
A9BPageSelect8000RW	equ	002ah
A9BPageSelect9000RW	equ	002bh
A9WControlExtraRW	equ	002ch
  A9RControlExtraRW record A9MSlaveIntEnable:1,A9MClkDiv:2,\
    			A9MClockEnable5:1,A9MClockEnable4:1,\
    			A9MClockEnable3:1,A9MClockEnable2:1,\
    			A9MClockEnable1:1,A9MSoundDir:1,\
    			A9MExonDisable:1,A9MBuzzFromFrc1OrTog:1,\
    			A9MBuzzTog:1,A9MKeyCol:4
  A9VKeyColHigh		equ	0
  A9VKeyColLow		equ	1
  A9VKeyCol0		equ	8
  A9VClkDiv1		equ	(3 shl A9MClkDiv)
  A9VClkDiv2		equ	(2 shl A9MClkDiv)
  A9VClkDiv3		equ	(1 shl A9MClkDiv)
  A9VClkDiv4		equ	(0 shl A9MClkDiv)
A9WPumpControlRW	equ	002eh
  A9RPumpControl record A9MVhPumpDc:4,A9MVhPumpBat:4,\
    			A9MLcdPump:4,A9MPump2:4
  A9VVhPumpBat		equ	(14 shl A9MVhPumpBat)
  A9VVhPumpBatSoft	equ	(4 shl A9MVhPumpBat)
  A9VVhPumpBatMedium	equ	(8 shl A9MVhPumpBat)
  A9VVhPumpDC		equ	(2 shl A9MVhPumpDc)
  A9VVhPumpDCSoft	equ	(1 shl A9MVhPumpDc)
  A9VLcdPump		equ	(7 shl A9MLcdPump)
  A9VLcdPumpSoft	equ	(1 shl A9MLcdPump)
  A9VPacksPumpSoft	equ	(15 shl A9MPump2)
  A9VVhPumpDelay	equ	100	; Milliseconds
  A9VLcdPumpDelay	equ	5	; Milliseconds
  A9VCC3OnDelay		equ	1	; Milliseconds
  A9VCCPacksDelay	equ	20	; Milliseconds    
  A9VCC2Delay		equ	10	; Milliseconds
A9WRtcLSWRW		equ	0080h
A9WRtcMSWRW		equ	0082h
A9WNullFrameW		equ	0084h
A9BSlaveDataR		equ	0088h
A9BSerialDataRW		equ	008ah
A9BSerialControlW	equ	008ch
A9BChannelSelectRW	equ	008eh
  A9RChannelSelect record A9MMultiplexEnable:1,A9MSerialClockRate:2,\
    			A9MPack5Enable:1,A9MPack4Enable:1,\
    			A9MPack3Enable:1,A9MPack2Enable:1,\
    			A9MPack1Enable:1
  A9VSClkRateMedium	equ	(0 shl A9MSerialClockRate)
  A9VSClkRateSpecial	equ	(1 shl A9MSerialClockRate)
  A9VSClkRateSlow	equ	(2 shl A9MSerialClockRate)
  A9VSClkRateFast	equ	(3 shl A9MSerialClockRate)
;
; Asic9 Dependent constants
;
ResetWatchDog		equ	A9WResetWatchDogW
SelectChannel1		equ	(mask A9MPack1Enable)
SelectChannel2		equ	(mask A9MPack2Enable)
SelectChannel3		equ	(mask A9MPack3Enable)
SelectChannel4		equ	(mask A9MPack4Enable)
SelectChannel5		equ	(mask A9MPack5Enable)
;
; Current usage values
;
IdleCurrent		equ	23
RunCurrent		equ	51
Asic5SerialCurrent	equ	54
Flash1ProgramCurrent	equ	76
Flash2ProgramCurrent	equ	99
Flash1EraseCurrent	equ	94
Flash2EraseCurrent	equ	129
;
; We add 26 because most of the work is under the NULL process.
; The value is 26 and not 28 because 10% of the time we are
; under the sound server.
;
SoundCurrentPlayV3	equ	(25+20)
SoundCurrentPlayV2	equ	(30+20)
SoundCurrentPlayV1	equ	(55+20)
SoundCurrentPlayV0	equ	(120+20)
;
; The value here must never equal one of the play values.
; It won't anyway in practise so this is not a big deal.
;
SoundCurrentRecord	equ	5
;
SCONTOUT macro
	out	A9BSerialControlW, al
	endm
;
SDATAOUT macro
	out	A9BSerialDataRW, al
	endm
;
SDATAIN macro
	in	al, A9BSerialDataRW
	endm
;
SBUSY	macro
	endm
;
SREAD	macro _REG
	mov	al, SerialReadSingle or _REG
	out	A9BSerialControlW, al
	in	al, A9BSerialDataRW
	endm
;
SREADM	macro _REG
	mov	al, SerialReadMulti or _REG
	out	A9BSerialControlW, al
	in	al, A9BSerialDataRW
	endm
;
SWRITE	macro _REG,_VAL
	mov	al, SerialWriteSingle or _REG
	out	A9BSerialControlW, al
	mov	al, _VAL
	out	A9BSerialDataRW, al
	endm
;
SWRITEM macro _REG,_VAL
	mov	al, SerialWriteMulti or _REG
	out	A9BSerialControlW, al
	mov	al, _VAL
	out	A9BSerialDataRW, al
	endm
;
SETSPEED macro _SPEED
	pushf
	cli
	in	al, A9BChannelSelectRW
	and	al, not (mask A9MSerialClockRate)
  ifidni <_SPEED>,<FAST>
	or	al, A9VSClkRateFast
  endif
  ifidni <_SPEED>,<NORMAL>
	or	al, A9VSClkRateMedium
  endif
  ifidni <_SPEED>,<SLOW>
	or	al, A9VSClkRateSlow
  endif
	out	A9BChannelSelectRW, al
	popf
	endm
;
XPUSHFCLI macro
	endm
XPOPF	macro
	endm
XNOP	macro
	endm
;
@HwNullFrame macro
	out	A9WNullFrameW, ax
        endm
endif
;
	.list

